package com.tudouji.project.harvest.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.harvest.domain.OpLocation;
import com.tudouji.project.harvest.service.IOpLocationService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 货运单相关操作的位置信息Controller
 * 
 * @author tudouji
 * @date 2022-10-27
 */
@RestController
@RequestMapping("/harvest/location")
public class OpLocationController extends BaseController
{
    @Autowired
    private IOpLocationService opLocationService;

    /**
     * 查询货运单相关操作的位置信息列表
     */
    @PreAuthorize("@ss.hasPermi('harvest:location:list')")
    @GetMapping("/list")
    public TableDataInfo list(OpLocation opLocation)
    {
        startPage();
        List<OpLocation> list = opLocationService.selectOpLocationList(opLocation);
        return getDataTable(list);
    }

    /**
     * 导出货运单相关操作的位置信息列表
     */
    @PreAuthorize("@ss.hasPermi('harvest:location:export')")
    @Log(title = "货运单相关操作的位置信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OpLocation opLocation)
    {
        List<OpLocation> list = opLocationService.selectOpLocationList(opLocation);
        ExcelUtil<OpLocation> util = new ExcelUtil<OpLocation>(OpLocation.class);
        return util.exportExcel(list, "location");
    }

    /**
     * 获取货运单相关操作的位置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('harvest:location:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(opLocationService.selectOpLocationById(guid));
    }

    /**
     * 新增货运单相关操作的位置信息
     */
    @PreAuthorize("@ss.hasPermi('harvest:location:add')")
    @Log(title = "货运单相关操作的位置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OpLocation opLocation)
    {
        return toAjax(opLocationService.insertOpLocation(opLocation));
    }

    /**
     * 修改货运单相关操作的位置信息
     */
    @PreAuthorize("@ss.hasPermi('harvest:location:edit')")
    @Log(title = "货运单相关操作的位置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OpLocation opLocation)
    {
        return toAjax(opLocationService.updateOpLocation(opLocation));
    }

    /**
     * 删除货运单相关操作的位置信息
     */
    @PreAuthorize("@ss.hasPermi('harvest:location:remove')")
    @Log(title = "货运单相关操作的位置信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(opLocationService.deleteOpLocationByIds(guids));
    }
}
